<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<#include "WEB-INF/view/_frag/meta.ftl">
<#include "WEB-INF/view/_frag/jscss.ftl">
<link href="${basePath}/assets/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="${basePath}/assets/h-ui.admin/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<title>修改密码</title>
</head>
<body>
<nav class="breadcrumb">
	<i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>系统管理<span class="c-gray en">&gt;</span> 修改密码 <a class="btn btn-success radius r" style="line-height: 1.6em; margin-top: 3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<article class="page-container">
	<form class="form form-horizontal" id="form-change-password">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">原密码：</label>
			<div class="formControls col-xs-8 col-sm-6">
				<input type="password" class="input-text" autocomplete="off" value="" id="old_password" name="old_password">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">新密码：</label>
			<div class="formControls col-xs-8 col-sm-6">
				<input type="password" class="input-text" autocomplete="off" value="" id="new_password" name="new_password">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">确认新密码：</label>
			<div class="formControls col-xs-8 col-sm-6">
				<input type="password" class="input-text" autocomplete="off" value="" id="confirm_password" name="confirm_password">
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>

<script type="text/javascript">

	$(function () {
		$("#form-change-password").validate({
			rules:{
				old_password: {
					required: true,
			        minlength: 6,
			        maxlength: 22
				},
				new_password: {
					required: true,
			        minlength: 6,
			        maxlength: 22
				},
				confirm_password: {
			        required: true,
			        minlength: 6,
			        equalTo: "#new_password"
				},
			},
			submitHandler: function(form) {
				changePassword();
			}
		});		
	});

	function changePassword() {
		
		var oldPassword = $("#old_password").val();
		var newPassword = $("#new_password").val();
		var url = "${basePath}/systemUser/ajaxChangeSystemUserPassword";
		var params = {
			'v.oldPassword': oldPassword,
			'v.newPassword': newPassword
		};
	
		$.post(url, params, function(res) {
			if (res == 0) {
				layer.alert("修改成功！", { icon: 0 });
			} else {
				layer.alert("原密码错误。", { icon: 0 });
			}
		});
		//清空、日志
	}
</script>

</body>
</html>